package cn.sc.allinpay.allfavour.business.cashiertrsdetailonline;

import com.alibaba.fastjson.JSONObject;

import cn.pai.mvp.callback.MpCallBack;
import cn.sc.allinpay.allfavour.base.connect.http.AppRequest;
import cn.sc.allinpay.allfavour.base.connect.http.RequestManager;
import cn.sc.allinpay.allfavour.base.model.BaseModel;
import cn.sc.allinpay.allfavour.business.common.data.OilRecord;

/**
 * 交易详情
 * author：pany
 * on 2017/12/5 14:44
 */
public class CashierTransDetailOnlineModel extends BaseModel {
    /**
     * 加油订单详情查询
     *
     * @param payNum   订单号
     * @param mpCallBack
     */
    public void reqQueryOilDetail(String payNum, final MpCallBack<OilRecord, String> mpCallBack) {
        RequestManager.reqQueryOilDetail(payNum, new AppRequest.RequestCall() {
            @Override
            protected void onSuccess(JSONObject response) {
                if (response.getString("code").equals("0000")) {
                    OilRecord oilRecord = response.getObject("data", OilRecord.class);
                    mpCallBack.onSuccess(oilRecord);
                } else {
                    mpCallBack.onFailure(response != null ? response.toString() : null, response.getString("msg"));
                }
            }

            @Override
            public void onFailure(JSONObject response, String message) {
                mpCallBack.onFailure(response != null ? response.toString() : null, message);
            }
        });
    }

    /**
     * 加油订单更新打印次数
     *
     * @param payNum   订单号
     * @param mpCallBack
     */
    public void reqQueryOilUpdate(String payNum, final MpCallBack<JSONObject, String> mpCallBack) {
        RequestManager.reqQueryOilUpdate(payNum, new AppRequest.RequestCall() {
            @Override
            protected void onSuccess(JSONObject response) {
                if (response.getString("code").equals("0000")) {
                    mpCallBack.onSuccess(response);
                } else {
                    mpCallBack.onFailure(response != null ? response.toString() : null, response.getString("msg"));
                }
            }

            @Override
            public void onFailure(JSONObject response, String message) {
                mpCallBack.onFailure(response != null ? response.toString() : null, message);
            }
        });
    }
}
